<template>
  <div class="range-input-container">
    <el-input v-model="minval" v-bind="$attrs" class="range-input-item" @input="handleInput" />
    <span>-</span>
    <el-input v-model="maxval" v-bind="$attrs" class="range-input-item" @input="handleInput" />
  </div>
</template>

<script>
export default {
  name: 'RangeInput',
  props: {
    value: {
      type: Array,
      default: null
    }
  },
  data() {
    return {
      minval: undefined,
      maxval: undefined
    }
  },
  computed: {
    range() {
      return [this.minval, this.maxval]
    }
  },
  watch: {
    value() {
      this.$emit('update:value', this.range)
    }
  },
  methods: {
    handleInput(_) {
      this.$emit('update:value', this.range)
    }
  }
}
</script>

<style scoped>
  .range-input-item {
    width: 60px;
  }
</style>
